package com.xuebusi.feign.consumer.controller;

import com.xuebusi.feign.consumer.entity.Product;
import com.xuebusi.feign.consumer.feign.ProductFeignClient;
import com.xuebusi.feign.consumer.vo.ResultVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    private ProductFeignClient productFeignClient;

    /**
     * 查询商品信息
     *
     * @param productId 商品id
     * @return
     */
    @GetMapping("/buy/{productId}")
    public ResultVO<Product> findProductById(@PathVariable("productId") Long productId) {
        return productFeignClient.findById(productId);
    }
}
